#include <bitset>
#include <iostream>
#include <string>
#include <vector>
#define lld long long
#define ENDL '\n'
#define LOG(var) std::cout << #var << " = " << (var) << ENDL
using std::bitset;
using std::cin;
using std::cout;
using std::string;
using std::vector;

void solve() {
  // body
  int n, m;
  cin >> n >> m;
  string x;
  cin >> x;

  int len = x.size();
  auto check = [&](bitset<8> bin) -> int {
    lld byte = bin.to_ullong();
    // unsigned char byte = static_cast<unsigned char>(bin.to_ulong());
    if (byte >= 0x00 and byte <= 0x7F)
      return 1;
    if (byte >= 80 and byte <= 0xDF)
      return 2;
    if (byte >= 0xE0 and byte <= 0xEF)
      return 3;
    else
      return 4;

    /*  if ((byte & 0x80) == 0x00)
       return 1;
     if ((byte & 0xE0) == 0xC0)
       return 2;
     if ((byte & 0xF0) == 0xE0)
       return 3;
     if ((byte & 0xF8) == 0xF0)
       return 4; */
    return -1;
  };

  std::vector<string> str;
  for (int i = 0; i < len;) {

    /*
      int value;
      std::istringstream iss(s);
      iss >> std::hex >> value; // value == 101
     */
    std::string s = x.substr(i, 2);
    int value = std::stoi(s, nullptr, 16);
    std::bitset<8> r(value);
    int times = check(r);
    // cout << times << ENDL;
    string ch = "";
    for (int j = 0; j < times; ++j) {
      ch += x.substr(i, 2);
      i += 2;
    }

    str.push_back(ch);
  }
  // cout << "SIZE =" << str.size();

  while (m--) {
    int pos, cnt;
    cin >> pos >> cnt;
    string s = "";
    int end = std::min(pos + cnt, (int)str.size());
    for (int i = pos; i < end; ++i) {
      s += str[i];
    }
    cout << s << ENDL;
  }
}

int main() {
  // body
  solve();
}

/*
65726963e8b0a2e58b87ceb1ceb2f09f9a80
65 72 69 63 e8 b0 a2 e5 8b 87 ce b1 ce b2 f0 9f 9a 80


input
18 4
65726963e8b0a2e58b87ceb1ceb2f09f9a80
0 5
5 4
5 5
2 5

output
65726963e8b0a2
e58b87ceb1ceb2f09f9a80
e58b87ceb1ceb2f09f9a80
6963e8b0a2e58b87ceb1

65 72 69 63 e8b0a2 e58b87 ceb1 ceb2 f09f9a80
0  1  2   3   4     5       6    7    8

01100101
01110010
01101001
01100011

11101000
10110000
10100010

11100101
10001011
10000111

11001110
10110001

11001110
10110010

11110000
10011111
10011010
10000000


*/